home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1999 November / SOTMC_Nov1999-Ultimate.iso / mac / REALbasic ƒ / Examples / Applications / 3DViewer ƒ / OOGL File Format < prev    next >
Encoding:
Text File  |  1999-02-10  |  48.6 KB  |  1,274 lines  |  [TEXT/R*ch]

  1. OOGL File Formats
  2. =================
  3.  
  4. The objects that you can load into Geomview are called OOGL objects.  OOGL 
  5. stands for "Object Oriented Graphics Library"; it is the library upon which 
  6. Geomview is built.  There are many different kinds of OOGL objects.  This 
  7. chapter gives syntactic descriptions of file formats for OOGL objects.  
  8. Examples of most file types live in Geomview's `data/geom' directory.
  9.  
  10. Conventions
  11. ===========
  12.  
  13. Syntax Common to All OOGL File Formats
  14. --------------------------------------
  15. Most OOGL object file formats are free-format ASCII -- any amount of white 
  16. space (blanks, tabs, newlines) may appear between tokens (numbers, key 
  17. words, etc.).  Line breaks are almost always insignificant, with a couple 
  18. of exceptions as noted.  Comments begin with # and continue to the end of 
  19. the line; they're allowed anywhere a newline is.  Binary formats are also 
  20. defined for several objects; See section Binary format, and the individual 
  21. object descriptions.  Typical OOGL objects begin with a key word 
  22. designating object type, possibly with modifiers indicating presence of 
  23. color information etc.  In some formats the key word is optional, for 
  24. compatibility with file formats defined elsewhere.  Object type is then 
  25. determined by guessing from the file suffix (if any) or from the data 
  26. itself.  Key words are case sensitive.  Some have optional prefix letters 
  27. indicating presence of color or other data; in this case the order of 
  28. prefixes is significant, e.g. CNMESH is meaningful but NCMESH is invalid.
  29.  
  30. File Names
  31. ----------
  32. When OOGL objects are read from disk files, the OOGL library uses the file 
  33. suffix to guess at the file type.  If the suffix is unrecognized, or if no 
  34. suffix is available (e.g. for an object being read from a pipe, or embedded 
  35. in another OOGL object), all known types of objects are tried in turn until 
  36. one accepts the data as valid.
  37.  
  38. Vertices
  39. --------
  40. Several objects share a common style of representing vertices with optional 
  41. per-vertex surface-normal and color.  All vertices within an object have 
  42. the same format, specified by the header key word.  All data for a vertex 
  43. is grouped together (as opposed to e.g. giving coordinates for all 
  44. vertices, then colors for all vertices, and so on).  The syntax is
  45.    
  46.    `x y z'   (3-D floating-point vertex coordinates) 
  47. or 
  48.    `x y z w' (4-D floating-point vertex coordinates) 
  49.  
  50. optionally followed by 
  51.  
  52.    `nx ny nz' (normalized 3-D surface-normal if present) 
  53.  
  54. optionally followed by 
  55.  
  56.    `r g b a'  (4-component floating-point color; if present, each 
  57. component in range 0..1. 
  58.                The a (alpha) component represents opacity: 0 transparent, 
  59. 1 opaque.) 
  60.                
  61. optionally followed by 
  62.  
  63.    `s t'   (two texture-coordinate values)
  64. or
  65.    `s t u' (three texture-coordinate values)
  66.  
  67.  
  68. Values are separated by white space, and line breaks are immaterial.  
  69. Letters in the object's header key word must appear in a specific order; 
  70. that's the reverse of the order in which the data is given for each vertex.  
  71. So a `CN4OFF' object's vertices contain first the 4-component space 
  72. position, then the 3-component normal, finally the 4-component color.  You 
  73. can't change the data order by changing the header key word; an `NCOFF' is 
  74. just not recognized.
  75.  
  76. Surface normal directions
  77. -------------------------
  78. Geomview uses normal vectors to determine how an object is shaded.  The 
  79. direction of the normal is significant in this calculation.  When normals 
  80. are supplied with an object, the direction of the normal is determined by 
  81. the data given.  When normals are not supplied with the object, Geomview 
  82. computes normal vectors automatically; in this case normals point toward 
  83. the side from which the vertices appear in counterclockwise order.  On 
  84. parametric surfaces (Bezier patches), the normal at point P(u,v) is in the 
  85. direction dP/du cross dP/dv.
  86.  
  87. Transformation matrices
  88. -----------------------
  89. Some objects incorporate 4x4 real matrices for homogeneous object 
  90. transformations.  These matrices act by multiplication on the right of 
  91. vectors.  Thus, if p is a 4-element row vector representing homogeneous 
  92. coordinates of a point in the OOGL object, and A is the 4x4 matrix, then 
  93. the transformed point is p' = p A. This matrix convention is common in 
  94. computer graphics; it's the transpose of that often used in mathematics, 
  95. where points are column vectors multiplied on the right of matrices.  Thus 
  96. for Euclidean transformations, the translation components appear in the 
  97. fourth row (last four elements) of A. A's last column (4th, 8th, 12th and 
  98. 16th elements) are typically 0, 0, 0, and 1 respectively.
  99.  
  100. Binary format
  101. -------------
  102. Many OOGL objects accept binary as well as ASCII file formats.  These files 
  103. begin with the usual ASCII token (e.g. CQUAD) followed by the word BINARY. 
  104. Binary data begins at the byte following the first newline after BINARY. 
  105. White space and a single comment may intervene, e.g.
  106.  
  107. OFF BINARY    # binary-format "OFF" data follows 
  108.  
  109. Binary data comprise 32-bit integers and 32-bit IEEE-format floats, both in 
  110. big-endian format (i.e., with most significant byte first).  This is the 
  111. native format for 'int's and 'float's on Sun-3's, Sun-4's, and Irises, 
  112. among others.  Binary data formats resemble the corresponding ASCII 
  113. formats, with ints and floats in just the places you'd expect.  There are 
  114. some exceptions though, specifically in the QUAD, OFF and COMMENT file 
  115. formats.  Details are given in the individual file format descriptions.  
  116. See section QUAD: collection of quadrilaterals, See section OFF Files, and 
  117. See section COMMENT Objects.  Binary OOGL objects may be freely mixed in 
  118. ASCII object streams:
  119.  
  120. LIST
  121. { = MESH BINARY
  122. ... binary data for mesh here ...
  123. }
  124. { = QUAD
  125.     1 0 0   0 0 1   0 1 0  0 1 0
  126. }
  127.  
  128. Note that ASCII data resumes immediately following the last byte of binary 
  129. data.  Naturally, it's impossible to embed comments inside a binary-format 
  130. OOGL object, though comments may appear in the header before the beginning 
  131. of binary data.
  132.  
  133. Embedded objects and external-object references
  134. -----------------------------------------------
  135. Some object types (LIST, INST) allow references to other OOGL objects, 
  136. which may appear literally in the data stream, be loaded from named disk 
  137. files, or be communicated from elsewhere via named objects.  Gcl commands 
  138. also accept geometry in these forms.  The general syntax is
  139.  
  140.  <oogl-object>  ::=
  141.     [ "{" ]
  142.         [ "define" symbolname ]
  143.         [ "appearance" appearance ]
  144.         [ ["="] object-keyword ...
  145.          | "<" filename
  146.          | ":" symbolname ]
  147.     [ "}" ]
  148.  
  149. where "quoted" items are literal strings (which appear without the quotes), 
  150. [bracketed] items are optional, and | denotes alternatives.  Curly braces, 
  151. when present, must match; the outermost set of curly braces is generally 
  152. required when the object is in a larger context, e.g. when it is part of a 
  153. larger object or embedded in a Geomview command stream.  For example, each 
  154. of the following three lines:
  155.  
  156.     { define fred   QUAD 1 0 0  0 0 1  0 1 0  1 0 0 }
  157.  
  158.     { appearance { +edge } LIST { < "file1" } { : fred } }
  159.  
  160.     VECT 1 2 0   2 0   0 0 0   1 1 2
  161.  
  162. is a valid OOGL object.  The last example is only valid when it is 
  163. delimited unambiguously by residing in its own disk file.  The "<" 
  164. construct causes a disk file to be read.  Note that this isn't a general 
  165. textual "include" mechanism; a complete OOGL object must appear in the 
  166. referenced file.  Files read using "<" are sought first in the directory of 
  167. the file which referred to them, if any; failing that, the normal search 
  168. path (set by Geomview's load-path command) is used.  The default search 
  169. looks first in the current directory, then in the Geomview data 
  170. directories.  The ":" construct allows references to symbols, created with 
  171. define.  A symbol's initial value is a null object.  When a symbol is 
  172. (re)defined, all references to it are automatically changed; this is a 
  173. crucial part of the support for interprocess communication.  Some future 
  174. version of the documentation should explain this better...  Again, white 
  175. space and line breaks are insignificant, and "#" comments may appear 
  176. anywhere.
  177.  
  178. Appearances
  179. -----------
  180. Geometric objects can have associated "appearance" information, specifying 
  181. shading, lighting, color, wireframe vs.  shaded-surface display, and so on.  
  182. Appearances are inherited through object hierarchies, e.g. attaching an 
  183. appearance to a LIST means that the appearance is applied to all the LIST's 
  184. members.  Some appearance-related properties are relegated to "material" 
  185. and "lighting" substructures.  Take care to note which properties belong to 
  186. which structure.  Here's an example appearance structure including values 
  187. for all attributes.  Order of attributes is unimportant.  As usual, white 
  188. space is irrelevant.  Boolean attributes may be preceded by "+" or "-" to 
  189. turn them on or off; "+" is assumed if only the attribute name appears.  
  190. Other attributes expect values.  A "*" prefix on any attribute, e.g. 
  191. "*+edge" or "*linewidth 2" or "material { *diffuse 1 1 .25 }", selects 
  192. "override" status for that attribute.
  193.  
  194. appearance {
  195.   +face               # (Do) draw faces of polygons.  On by default.
  196.   -edge               # (Don't) draw edges of polygons
  197.   +vect               # (Do) draw VECTs.  On by default.
  198.   -transparent        # (Disable) transparency. enabling transparency 
  199.                       # does NOT result in a correct Geomview picture, 
  200.                       # but alpha values are used in RenderMan snapshots.
  201.   -normal             # (Do) draw surface-normal vectors
  202.   normscale 1         # ... with length 1.0 in object coordinates
  203.  
  204.   +evert              # do evert polygon normals where needed so as
  205.                       #   to always face the camera
  206.  
  207.   -texturing          # (Disable) texture mapping
  208.   -backcull           # (Don't) discard clockwise-oriented faces
  209.   -concave            # (Don't) expect and handle concave polygons
  210.   -shadelines          # (Don't) shade lines as if they were lighted cylinders
  211.               # These four are only effective where the graphics system
  212.               # supports them, namely on GL and Open GL.
  213.  
  214.   -keepcolor          # Normally, when N-D positional coloring is enabled as
  215.               # with geomview's (ND-color ...) command, all
  216.               # objects' colors are affected.  But, objects with the
  217.               # "+keepcolor" attribute are immune to N-D coloring.
  218.  
  219.   shading smooth      # or "shading constant" or "shading flat" or
  220.                       # or "shading csmooth".
  221.                       # smooth = Gouraud shading, flat = faceted,
  222.                       # csmooth = smoothly interpolated but unlighted.
  223.  
  224.   linewidth 1         # lines, points, and edges are 1 pixel wide.
  225.  
  226.   patchdice 10 10     # subdivide Bezier patches this finely in u and v
  227.  
  228.   material {         # Here's a material definition;
  229.                       # it could also be read from a file as in
  230.                       #  "material < file.mat"
  231.  
  232.       ka  1.0         # ambient reflection coefficient.
  233.       ambient .3 .5 .3 # ambient color (red, green, blue components)
  234.                       # The ambient contribution to the shading is
  235.                       # the product of ka, the ambient color,
  236.                       # and the color of the ambient light.
  237.  
  238.       kd  0.8         # diffuse-reflection coefficient.
  239.       diffuse .9 1 .4 # diffuse color.
  240.                         # (In "shading constant" mode, the surface
  241.                         # is colored with the diffuse color.)
  242.  
  243.       ks 1.0          # specular reflection coefficient.
  244.       specular 1 1 1  # specular (highlight) color.
  245.       shininess  25   # specular exponent; larger values give
  246.                       # sharper highlights.
  247.  
  248.       backdiffuse .7 .5 0 # back-face color for two-sided surfaces
  249.                         # If defined, this field determines the diffuse
  250.                         # color for the back side of a surface.
  251.                         # It's implemented by the software shader, and
  252.                         # by hardware shading on GL systems which support
  253.                         # two-sided lighting, and under Open GL.
  254.  
  255.       alpha   1.0     # opacity; 0 = transparent (invisible), 1 = opaque.
  256.                       # Ignored when transparency is disabled.
  257.  
  258.       edgecolor   1 1 0  # line & edge color
  259.  
  260.       normalcolor 0 0 0  # color for surface-normal vectors
  261.   }
  262.  
  263.   lighting {         # Lighting model
  264.  
  265.       ambient  .3 .3 .3  # ambient light
  266.  
  267.       replacelights   # "Use only the following lights to
  268.                       # illuminate the objects under this
  269.                       # appearance."
  270.                       # Without "replacelights", any lights listed
  271.                       # are added to those already in the scene.
  272.  
  273.                       # Now a collection of sample lights:
  274.       light { 
  275.           color  1 .7 .6      # light color
  276.           position  1 0 .5 0  # light position [distant light]
  277.                               # given in homogeneous coordinates.
  278.                               # With fourth component = 0,
  279.                               # this means a light coming from
  280.                               # direction (1,0,.5).
  281.       }
  282.  
  283.       light {                        # Another light.
  284.           color 1 1 1
  285.           position  0 0 .5 1  # light at finite position ...
  286.           location camera     # specified in camera coordinates.
  287.                               # (Since the camera looks toward -Z,
  288.                               # this example places the light
  289.                               # .5 unit behind the eye.)
  290.           # Possible "location" keywords:
  291.           #  global    light position is in world (well, universe) 
  292. coordinates
  293.           #             This is the default if no location specified.
  294.           #  camera   position is in the camera's coordinate system
  295.           #  local    position is in the coordinate system where
  296.           #                   the appearance was defined
  297.       }
  298.   }                   # end lighting model
  299.   texture {
  300.         clamp st               # or "s" or "t" or "none"
  301.         file lump.tiff         # file supplying texture-map image
  302.         alphafile mask.pgm.Z   # file supplying transparency-mask image
  303.         apply blend            # or "modulate" or "decal"
  304.         transform  1 0 0 0     # surface (s,t,0,1) * tfm -> texture coords
  305.                    0 1 0 0
  306.                    0 0 1 0
  307.                   .5 0 0 1
  308.  
  309.         background 1 0 0 1     # relevant for "apply blend"
  310.   }
  311. }                     # end appearance
  312.  
  313. There are rules for inheritance of appearance attributes when several are 
  314. imposed at different levels in the hierarchy.  For example, Geomview 
  315. installs a backstop appearance which provides default values for most 
  316. parameters; its control panels install other appearances which supply new 
  317. values for a few attributes; user-supplied geometry may also contain 
  318. appearances.  The general rule is that the child's appearance (the one 
  319. closest to the geometric primitives) wins.  Further, appearance controls 
  320. with "override" status (e.g. *+face or material { *diffuse 1 1 0 }) win 
  321. over those without it.  Geomview's appearance controls use the "override" 
  322. feature so as to be effective even if user-supplied objects contain their 
  323. own appearance settings.  However, if a user-supplied object contains an 
  324. appearance field with override status set, that property will be immune to 
  325. Geomview's controls.
  326.  
  327. Texture Mapping
  328. ---------------
  329. Some platforms support texture-mapped objects.  (On those which don't, 
  330. attempts to use texture mapping are silently ignored.)  A texture is 
  331. specified as part of an appearance structure, as in See section 
  332. Appearances.  Briefly, one provides a texture image, which is considered to 
  333. lie in a square in (s,t) parameter space in the range 0 <= s <= 1, 0 <= t 
  334. <= 1.  Then one provides a geometric primitive, with each vertex tagged 
  335. with (s,t) texture coordinates.  If texturing is enabled, the appropriate 
  336. portion of the texture image is pasted onto each face of the textured 
  337. object.  There is (currently) no provision for inheritance of part of a 
  338. texture structure; if the texture keyword is mentioned in an appearance, it 
  339. supplants any other texture specification.  The appearance attribute 
  340. texturing controls whether textures are used; there's no performance 
  341. penalty for having texture { ...  } fields defined when texturing is off.  
  342. The available fields are:
  343.  
  344. clamp    none  -or-  s  -or-  t  -or-  st
  345.   Determines the meaning of texture coordinates outside the range 0..1.
  346.   With clamp none, the default, coordinates are interpreted
  347.   modulo 1, so (s,t) = (1.25,0), (.25,0), and (-.75,0) all refer to
  348.   the same point in texture space.  With s or t or
  349.   st, either or both of s- or t-coordinates less than 0 or
  350.   greater than 1 are clamped to 1 or 0, respectively.
  351.  
  352. file    filename
  353. alphafile    filename
  354.   Specifies image file(s) containing the texture.
  355.   The file file's image specifies color or lightness information;
  356.   the alphafile if present, specifies a transparency ("alpha") mask;
  357.   where the mask is zero, pixels are simply not drawn.
  358.   Several image file formats are available; the file type must be
  359.   indicated by the last few characters of the file name:
  360.     .ppm or .ppm.Z or .ppm.gz  24-bit 3-color image in PPM format
  361.     .pgm or .pgm.Z or .pgm.gz  8-bit grayscale image in PGM format
  362.     .sgi or .sgi.Z or .sgi.gz  8-bit, 24-bit, or 32-bit SGI image
  363.     .tiff                8-bit or 24-bit TIFF image
  364.     .gif               GIF image
  365.   (Though 4-channel TIFF images are possible, and could
  366.   represent both color and transparency information in one image,
  367.   that's not supported in geomview at present.)
  368.   For this feature to work, some programs must be available in
  369.   geomview's search path:
  370.     zcat  for .Z files
  371.     gzip  for .gz files
  372.     tifftopnm for .tiff files
  373.     giftoppm for .gif files
  374.  
  375.   If an alphafile image is supplied, it must be the same size
  376.   as the file image.
  377.  
  378.  
  379. apply    modulate  -or-  blend  -or-  decal
  380.   Indicates how the texture image is applied to the surface.
  381.   Here the "surface color" means the color that surface would have
  382.   in the absence of texture mapping.
  383.  
  384.   With modulate, the default, the texture color (or lightness,
  385.   if textured by a gray-scale image) is multiplied by the surface color.
  386.  
  387.   With blend, texture blends between the background color
  388.   and the surface color.  The file parameter must specify a
  389.   gray-scale image.  Where the texture image is 0, the surface color is
  390.   unaffected; where it's 1, the surface is painted in the color given
  391.   by background; and color is interpolated for intermediate values.
  392.  
  393.   With decal, the file parameter must specify a
  394.   3-color image.  If an alphafile parameter is present,
  395.   its value interpolates between the surface color (where alpha=0)
  396.   and the texture color (where alpha=1).  Lighting does not affect the
  397.   texture color in decal mode; effectively the texture is
  398.   constant-shaded.
  399.  
  400. background  R G B A
  401.   Specifies a 4-component color, with R, G, B, and A floating-point
  402.   numbers normally in the range 0..1, used when apply blend
  403.   is selected.
  404.  
  405. transform transformation-matrix
  406.   Expects a list of 16 numbers, or one of the other ways of representing
  407.   a transformation (: handlename or < filename).
  408.   The 4x4 transformation matrix is applied to texture coordinates,
  409.   in the sense of a 4-component row vector (s,t,0,1) multiplied on
  410.   the left of the matrix, to produce new coordinates (s',t')
  411.   which actually index the texture.
  412.  
  413.  
  414. Object File Formats
  415. ===================
  416.  
  417. QUAD: collection of quadrilaterals
  418. ----------------------------------
  419. The conventional suffix for a QUAD file is `.quad'. 
  420. The file syntax is 
  421.  
  422.    [C][N][4]QUAD  -or-  [C][N][4]POLY           # Key word
  423.    vertex  vertex  vertex  vertex  # 4*N vertices for some N
  424.    vertex  vertex  vertex  vertex
  425.    ...
  426.  
  427. The leading key word is [C][N][4]QUAD or [C][N][4]POLY, where the optional 
  428. C and N prefixes indicate that each vertex includes colors and normals 
  429. respectively.  That is, these files begin with one of the words QUAD CQUAD 
  430. NQUAD CNQUAD POLY CPOLY NPOLY CNPOLY (but not NCQUAD or NCPOLY).  QUAD and 
  431. POLY are synonymous; both forms are allowed just for compatibility with 
  432. ChapReyes.
  433.  
  434. Following the key word is an arbitrary number of groups of four vertices, 
  435. each group describing a quadrilateral.  See the Vertex syntax above.  The 
  436. object ends at end-of-file, or with a closebrace if incorporated into an 
  437. object reference (see above).
  438.  
  439. A QUAD BINARY file format is accepted; See section Binary format.  The 
  440. first word of binary data must be a 32-bit integer giving the number of 
  441. quads in the object; following that is a series of 32-bit floats, arranged 
  442. just as in the ASCII format.
  443.  
  444. MESH: rectangularly-connected mesh
  445. ----------------------------------
  446. The conventional suffix for a MESH file is `.mesh'. 
  447. The file syntax is 
  448.  
  449. [U][C][N][Z][4][u][v][n]MESH # Key word
  450. [Ndim]                 # Space dimension, present only if nMESH
  451. Nu Nv            # Mesh grid dimensions
  452.                              # Nu*Nv vertices, in format specified
  453.                              # by initial key word
  454. vertex(u=0,v=0)  vertex(1,0)  ... vertex(Nu-1,0)
  455. vertex(0,1) ...    vertex(Nu-1,1)
  456. ...
  457. vertex(0,Nv-1) ... vertex(Nu-1,Nv-1)
  458.  
  459. The key word is [U][C][N][Z][4][u][v][n]MESH. The optional prefix 
  460. characters mean: 
  461.  
  462. `U' 
  463. Each vertex includes a 3-component texture space parameter. The first two 
  464. components are the usual S and T texture parameters for that vertex; the 
  465. third should be specified as zero. 
  466.  
  467. `C' 
  468. Each vertex (see Vertices above) includes a 4-component color. 
  469.  
  470. `N' 
  471. Each vertex includes a surface normal vector. 
  472.  
  473. `Z' 
  474. Of the 3 vertex position values, only the Z component is present; X and Y 
  475. are omitted, and assumed to equal the mesh (u,v) coordinate so X ranges 
  476. from 0 .. (Nu-1), Y from 0 .. (Nv-1) where Nu and Nv are the mesh 
  477. dimensions -- see below. 
  478.  
  479. `4' 
  480. Vertices are 4D, each consists of 4 floating values. Z and 4 cannot both 
  481. be present. 
  482.  
  483. `u' 
  484. The mesh is wrapped in the u-direction, so the (0,v)'th vertex is 
  485. connected to the (Nu-1,v)'th for all v. 
  486.  
  487. `v' 
  488. The mesh is wrapped in the v-direction, so the (u,0)'th vertex is 
  489. connected to the (u,Nv-1)'th for all u. Thus a u-wrapped or v-wrapped mesh 
  490. is topologically a cylinder, while a uv-wrapped mesh is a torus. 
  491.  
  492. `n' 
  493. Specifies a mesh whose vertices live in a higher dimensional space. The 
  494. dimension follows the "MESH" keyword. Each vertex then has Ndim 
  495. components. 
  496.  
  497.  
  498. Note that the order of prefix characters is significant; a colored, 
  499. u-wrapped mesh is a CuMESH not a uCMESH. Following the mesh header are 
  500. integers Nu and Nv, the dimensions of the mesh.
  501.  
  502. Then follow Nu*Nv vertices, each in the form given by the header.  They 
  503. appear in v-major order, i.e. if we name each vertex by (u,v) then the 
  504. vertices appear in the order
  505.  
  506. (0,0) (1,0) (2,0) (3,0) ...  (Nu-1,0)
  507. (0,1) (1,1) (2,1) (3,1) ...  (Nu-1,1)
  508. ...
  509. (0,Nv-1)        ...  (Nu-1,Nv-1)
  510.  
  511. A MESH BINARY format is accepted; See section Binary format.  The values of 
  512. Nu and Nv are 32-bit integers; all other values are 32-bit floats.
  513.  
  514. Bezier Surfaces
  515. ---------------
  516. The conventional file suffixes for Bezier surface files are `.bbp' or 
  517. `.bez'.  A file with either suffix may contain either type of patch.  
  518. Syntax:
  519.  
  520.   [ST]BBP -or- [C]BEZ<Nu><Nv><Nd>[_ST]
  521.             # Nu, Nv are u- and v-direction 
  522.             # polynomial degrees in range 1..6
  523.             # Nd = dimension: 3->3-D, 4->4-D (rational)
  524.             # (The '<' and '>' do not appear in the input.)
  525.             # Nu,Nv,Nd are each a single decimal digit.
  526.             # BBP form implies Nu=Nv=Nd=3 so BBP = BEZ333.
  527.  
  528.         # Any number of patches follow the header
  529.             # (Nu+1)*(Nv+1) patch control points
  530.             # each 3 or 4 floats according to header
  531.   vertex(u=0,v=0)  vertex(1,0) ... vertex(Nu,0)
  532.   vertex(0,1)               ... vertex(Nu,1)
  533.   ...
  534.   vertex(0,Nv)           ... vertex(Nu,Nv)
  535.  
  536.             # ST texture coordinates if mentioned in header
  537.   S(u=0,v=0)    T(0,0)    S(0,Nv) T(0,Nv)
  538.   S(Nu,0)    T(Nu,0)    S(Nu,Nv) T(Nu,Nv)
  539.  
  540.             # 4-component float (0..1) R G B A colors
  541.             # for each patch corner if mentioned in header
  542.   RGBA(0,0)   RGBA(0,Nv)
  543.   RGBA(Nu,0)  RGBA(Nu,Nv)
  544.  
  545. These formats represent collections of Bezier surface patches, of degrees 
  546. up to 6, and with 3-D or 4-D (rational) vertices.
  547.  
  548. The header keyword has the forms [ST]BBP or [C]BEZ<Nu><Nv><Nd>[_ST] (the 
  549. '<' and '>' are not part of the keyword.  The ST prefix on BBP, or _ST 
  550. suffix on BEZuvn, indicates that each patch includes four pairs of 
  551. floating-point texture-space coordinates, one for each corner of the patch.
  552.  
  553. The C prefix on BEZuvn indicates a colored patch, including four sets of 
  554. four-component floating-point colors (red, green, blue, and alpha) in the 
  555. range 0..1, one color for each corner.  Nu and Nv, each a single digit in 
  556. the range 1..6, are the patch's polynomial degree in the u and v direction 
  557. respectively.  Nd is the number of components in each patch vertex, and 
  558. must be either 3 for 3-D or 4 for homogeneous coordinates, that is, 
  559. rational patches.  BBP patches are bicubic patches with 3-D vertices, so 
  560. BBP = BEZ333 and STBBP = BEZ333_ST.
  561.  
  562. Any number of patches follow the header.  Each patch comprises a series of 
  563. patch vertices, followed by optional (s,t) texture coordinates, followed by 
  564. optional (r,g,b,a) colors.  Each patch has (Nu+1)*(Nv+1) vertices in 
  565. v-major order, so that if we designate a vertex by its control point 
  566. indices (u,v) the order is
  567.  
  568.      (0,0) (1,0) (2,0) ...  (Nu,0)
  569.      (0,1) (1,1) (2,1) ...  (Nu,1)
  570.      ...
  571.      (0,Nv)            ...  (Nu,Nv)
  572.  
  573. with each vertex containing either 3 or 4 floating-point numbers as 
  574. specified by the header. If the header calls for ST coordinates, four 
  575. pairs of floating-point numbers follow: the texture-space coordinates for 
  576. the (0,0), (Nu,0), (0,Nv), and (Nu,Nv) corners of the patch, respectively. 
  577. If the header calls for colors, four four-component (red, green, blue, 
  578. alpha) floating-point colors follow, one for each patch corner. 
  579. The series of patches ends at end-of-file, or with a closebrace if 
  580. incorporated in an object reference. 
  581.  
  582. OFF Files
  583. ---------
  584. The conventional suffix for OFF files is `.off'. 
  585. Syntax: 
  586.  
  587. [ST][C][N][4][n]OFF    # Header keyword
  588. [Ndim]        # Space dimension of vertices, present only if nOFF
  589. NVertices  NFaces  NEdges   # NEdges not used or checked
  590.  
  591. x[0]  y[0]  z[0]    # Vertices, possibly with normals,
  592.             # colors, and/or texture coordinates, in that order,
  593.             # if the prefixes N, C, ST
  594.             # are present.
  595.             # If 4OFF, each vertex has 4 components,
  596.             # including a final homogeneous component.
  597.             # If nOFF, each vertex has Ndim components.
  598.             # If 4nOFF, each vertex has Ndim+1 components.
  599. ...
  600. x[NVertices-1]  y[NVertices-1]  z[NVertices-1]
  601.  
  602.                 # Faces
  603.                 # Nv = # vertices on this face
  604.                 # v[0] ... v[Nv-1]: vertex indices
  605.                 #        in range 0..NVertices-1
  606. Nv  v[0] v[1] ... v[Nv-1]  colorspec
  607. ...
  608.                 # colorspec continues past v[Nv-1]
  609.                 # to end-of-line; may be 0 to 4 numbers
  610.                 # nothing: default
  611.                 # integer: colormap index
  612.                 # 3 or 4 integers: RGB[A] values 0..255
  613.             # 3 or 4 floats: RGB[A] values 0..1
  614.  
  615. OFF files (name for "object file format") represent collections of planar 
  616. polygons with possibly shared vertices, a convenient way to describe 
  617. polyhedra.  The polygons may be concave but there's no provision for 
  618. polygons containing holes.
  619.  
  620. An OFF file may begin with the keyword OFF; it's recommended but optional, 
  621. as many existing files lack this keyword.  Three ASCII integers follow: 
  622. NVertices, NFaces, and NEdges.  Thse are the number of vertices, faces, and 
  623. edges, respectively.  Current software does not use nor check NEdges; it 
  624. needn't be correct but must be present.  The vertex coordinates follow: 
  625. dimension * Nvertices floating-point values.  They're implicitly numbered 0 
  626. through NVertices-1.  dimension is either 3 (default) or 4 (specified by 
  627. the key character 4 directly before OFF in the keyword).  Following these 
  628. are the face descriptions, typically written with one line per face.  Each 
  629. has the form
  630.  
  631.    N  Vert1 Vert2 ... VertN  [color]
  632.  
  633. Here N is the number of vertices on this face, and Vert1 through VertN are 
  634. indices into the list of vertices (in the range 0..NVertices-1).  The 
  635. optional color may take several forms.  Line breaks are significant here: 
  636. the color description begins after VertN and ends with the end of the line 
  637. (or the next # comment).  A color may be:
  638.  
  639.    nothing                               (the default color)
  640.    one integer                           (index into "the" colormap; see 
  641. below)
  642.    three or four integers                (RGB and possibly alpha values in 
  643. the range 0..255)
  644.    three or four floating-point numbers  (RGB and possibly alpha values in 
  645. the range 0..1)
  646.  
  647.  
  648. For the one-integer case, the colormap is currently read from the file 
  649. `cmap.fmap' in Geomview's `data' directory.  Some better mechanism for 
  650. supplying a colormap is likely someday.  The meaning of "default color" 
  651. varies.  If no face of the object has a color, all inherit the 
  652. environment's default material color.  If some but not all faces have 
  653. colors, the default is gray (R,G,B,A=.666).
  654.  
  655. A [ST][C][N][n]OFF BINARY format is accepted; See section Binary format.  
  656. It resembles the ASCII format in almost the way you'd expect, with 32-bit 
  657. integers for all counters and vertex indices and 32-bit floats for vertex 
  658. positions (and texture coordinates or vertex colors or normals if 
  659. COFF/NOFF/CNOFF/STCNOFF/etc.  format).
  660.  
  661. Exception: each face's vertex indices are followed by an integer indicating 
  662. how many color components accompany it.  Face color components must be 
  663. floats, not integer values.  Thus a colorless triangular face might be 
  664. represented as
  665.  
  666. int int int int int
  667. 3   17   5   9   0
  668.  
  669. while the same face colored red might be 
  670.  
  671. int int int int int float float float float
  672.  3  17   5   9   4   1.0   0.0   0.0   1.0
  673.  
  674.  
  675. VECT Files
  676. ----------
  677. The conventional suffix for VECT files is `.vect'. 
  678. Syntax: 
  679.  
  680. [4]VECT
  681. NPolylines  NVertices  NColors
  682.  
  683. Nv[0] ... Nv[NPolylines-1]     # number of vertices
  684.                                # in each polyline
  685.  
  686. Nc[0] ... Nc[NPolylines-1]     # number of colors supplied
  687.                                # in each polyline
  688.  
  689. Vert[0] ... Vert[NVertices-1]  # All the vertices
  690.                                # (3*NVertices floats)
  691.  
  692. Color[0] ... Color[NColors-1]  # All the colors
  693.                                # (4*NColors floats, RGBA)
  694.  
  695. VECT objects represent lists of polylines (strings of connected line 
  696. segments, possibly closed). A degenerate polyline can be used to represent 
  697. a point. 
  698.  
  699. A VECT file begins with the key word VECT or 4VECT and three integers: 
  700. NLines, NVertices, and NColors. Here NLines is the number of polylines in 
  701. the file, NVertices the total number of vertices, and NColors the number 
  702. of colors as explained below. 
  703.  
  704. Next come NLines integers 
  705.  
  706. Nv[0] Nv[1] Nv[2] ... Nv[NLines-1] 
  707.  
  708. giving the number of vertices in each polyline. A negative number 
  709. indicates a closed polyline; 1 denotes a single-pixel point. The sum (of 
  710. absolute values) of the Nv[i] must equal NVertices. 
  711.  
  712. Next come NLines more integers Nc[i]: the number of colors in each 
  713. polyline. Normally one of three values: 
  714.  
  715. 0           No color is specified for this polyline.  It's drawn in the 
  716.             same color as the previous polyline.
  717.  
  718. 1           A single color is specified.  The entire polyline is drawn in 
  719.             that color.
  720.  
  721. abs(Nv[i]) Each vertex has a color.  Either each segment is 
  722.        drawn in the corresponding color, or the colors are smoothly 
  723.        interpolated along the line segments, depending on the 
  724.        implementation.
  725.  
  726.  
  727. The sum of the Nc[i] must equal NColors.  Next come NVertices groups of 3 
  728. or 4 floating-point numbers: the coordinates of all the vertices.  If the 
  729. keyword is 4VECT then there are 4 values per vertex.  The first abs(Nv[0]) 
  730. of them form the first polyline, the next abs(Nv[1]) form the second and so 
  731. on.
  732.  
  733. Finally NColors groups of 4 floating-point numbers give red, green, blue 
  734. and alpha (opacity) values.  The first Nc[0] of them apply to the first 
  735. polyline, and so on.
  736.  
  737. A VECT BINARY format is accepted; See section Binary format.  The binary 
  738. format exactly follows the ASCII format, with 32-bit ints where integers 
  739. appear, and 32-bit floats where real values appear.
  740.  
  741. SKEL Files
  742. ----------
  743. SKEL files represent collections of points and polylines, with shared 
  744. vertices.  The conventional suffix for SKEL files is `.skel'.  Syntax:
  745.  
  746. [4][n]SKEL
  747. [NDim]                # Vertex dimension, present only if nSKEL
  748. NVertices  NPolylines
  749.  
  750. x[0]  y[0]  z[0]      # Vertices
  751.                       # (if nSKEL, each vertex has NDim components)
  752. ...
  753. x[NVertices-1]  y[NVertices-1]  z[NVertices-1]
  754.  
  755.                         # Polylines
  756.                         # Nv = # vertices on this polyline (1 = point)
  757.                         # v[0] ... v[Nv-1]: vertex 
  758. indices                        #               in range 0..NVertices-1
  759. Nv  v[0] v[1] ... v[Nv-1]  [colorspec]
  760. ...
  761.                         # colorspec continues past v[Nv-1]
  762.                         # to end-of-line; may be nothing, or 3 or 4 
  763. numbers.
  764.                         # nothing: default color
  765.             # 3 or 4 floats: RGB[A] values 0..1
  766.  
  767. The syntax resembles that of OFF files, with a table of vertices followed 
  768. by a sequence of polyline descriptions, each referring to vertices by 
  769. index in the table. Each polyline has an optional color. 
  770. For nSKEL objects, each vertex has NDim components. For 4nSKEL objects, 
  771. each vertex has NDim+1 components; the final component is the homogeneous 
  772. divisor. 
  773. No BINARY format is implemented as yet for SKEL objects. 
  774.  
  775. SPHERE Files
  776. ------------
  777. The conventional suffix for SPHERE files is `.sph'. 
  778.  
  779. SPHERE
  780. Radius
  781. Xcenter Ycenter Zcenter
  782.  
  783. Sphere objects are drawn using rational Bezier patches, which are diced 
  784. into meshes; their smoothness, and the time taken to draw them, depends on 
  785. the setting of the dicing level, 10x10 by default. From Geomview, the 
  786. Appearance panel, the <N>ad keyboard command, or a dice nu nv Appearance 
  787. attribute sets this. 
  788.  
  789. INST Files
  790. ----------
  791. The conventional suffix for a INST file is `.inst'. 
  792.  
  793. There is no INST BINARY format. 
  794.  
  795. An INST applies a 4x4 transformation to another OOGL object.  It begins 
  796. with INST followed by these sections which may appear in any order:
  797.  
  798. geom oogl-object
  799.  
  800. specifies the OOGL object to be instantiated.  See section Embedded objects 
  801. and external-object references, for the syntax of an oogl-object.  The 
  802. keyword unit is a synonym for geom.
  803.  
  804. transform   ["{"] 4x4 transform ["}"]
  805.  
  806. specifies a single transformation matrix.  Either the matrix may appear 
  807. literally as 16 numbers, or there may be a reference to a "transform" 
  808. object, i.e.
  809.  
  810.     "<" file-containing-4x4-matrix
  811.  
  812. or 
  813.  
  814.     ":" symbol-representing-transform-object>
  815.  
  816. Another way to specify the transformation is 
  817.  
  818. transforms
  819.     oogl-object
  820.  
  821. The oogl-object must be a TLIST object (list of transformations) object, or 
  822. a LIST whose members are ultimately TLIST objects.  In effect, the 
  823. transforms keyword takes a collection of 4x4 matrices and replicates the 
  824. geom object, making one copy for each 4x4 matrix.
  825.  
  826. If no transform nor transforms keyword appears, no transformation is 
  827. applied (actually the identity is applied).  You could use this for, e.g., 
  828. wrapping an appearance around an externally-supplied object, though a 
  829. single-membered LIST would do this more efficiently.  See section 
  830. Transformation matrices, for the matrix format.
  831.  
  832. Two more INST fields are accepted: location and origin. 
  833.  
  834. location [global or camera or ndc or screen or local]
  835.  
  836. Normally an INST specifies a position relative to its parent object; the 
  837. location field allows putting an object elsewhere.
  838.  
  839. * location global attaches the object to the global (a.k.a. universe) 
  840. coordinate system -- the same as that in which geomview's World objects, 
  841. alien geometry, and cameras are placed.
  842.  
  843. * location camera places the object relative to the camera.  (Thus if there 
  844. are multiple views, it may appear in a different spatial position in each 
  845. view.)  The center of the camera's view is along its negative Z axis; 
  846. positive X is rightward, positive Y upward.  Normally the units of camera 
  847. space are the same as global coordinates.  When a camera is reset, the 
  848. global origin is at (0,0,-3.0).
  849.  
  850. * location ndc places the object relative to the normalized unit cube into 
  851. which the camera's projection (perspective or orthographic) maps the 
  852. visible world.  X, Y, and Z are each in the range from -1 to +1, with Z = 
  853. -1 the near and Z = +1 the far clipping plane, and X and Y increasing 
  854. rightward and upward respectively.  Thus something like
  855.  
  856. INST  transform  1 0 0 0  0 1 0 0  0 0 1 0  -.9 -.9 -.999 1
  857.       location ndc
  858.       geom < label.vect
  859.  
  860. pastes label.vect onto the lower left corner of each window, and in front 
  861. of nearly everything else, assuming label.vect's contents lie in the 
  862. positive quadrant of the X-Y plane.  It's tempting to use -1 rather than 
  863. -.999 as the Z component of the position, but that may put the object just 
  864. nearer than the near clipping plane and make it (partially) invisible, due 
  865. to floating-point error.
  866.  
  867. * location screen places the object in screen coordinates.  The range of Z 
  868. is still -1 through +1 as for ndc coordinates; X and Y are measured in 
  869. pixels, and range from (0,0) at the lower left corner of the window, 
  870. increasing rightward and upward.
  871.  
  872. location local is the default; the object is positioned relative to its 
  873. parent.
  874.  
  875. origin [global or camera or ndc or screen or local] x y z
  876.  
  877. The origin field translates the contents of the INST to place the origin at 
  878. the specified point of the given coordinate system.  Unlike location, it 
  879. doesn't change the orientation, only the choice of origin.  Both location 
  880. and origin can be used together.  So for example
  881.  
  882. { INST
  883.   location screen
  884.   origin ndc 0 0 -.99
  885.   geom { < xyz.vect }
  886.   transform { 100 0 0 0  0 100 0 0  0 0 -.009 0   0 0 0 1 }
  887. }
  888.  
  889. places xyz.vect's origin in the center of the window, just beyond the near 
  890. clipping plane.  The unit-length X and Y edges are scaled to be just 100 
  891. screen units -- pixels -- long, regardless of the size of the window.
  892.  
  893. INST Examples
  894.  
  895. Here are some examples of INST files 
  896.  
  897. INST
  898.      unit < xyz.vect
  899.      transform {
  900.         1 0 0 0
  901.         0 1 0 0
  902.         0 0 1 0
  903.         1 3 0 1
  904.      }
  905.  
  906.  
  907. { appearance { +edge  material { edgecolor 1 1 0 } }
  908.     INST geom < mysurface.quad }
  909.  
  910.  
  911. {INST transform {: T} geom {<dodec.off}}
  912.  
  913.  
  914. { INST
  915.      transforms
  916.          { LIST
  917.          { < some-matrices.prj }
  918.          { < others.prj }
  919.          { TLIST <still more of them> }
  920.          
  921.          }
  922.      geom
  923.          { # stuff replicated by all the above matrices
  924.          ...
  925.          }
  926. }
  927.  
  928. This one resembles the origin example in the section above, but makes the X 
  929. and Y edges be 1/4 the size of the window (1/4, not 1/2, since the range of 
  930. ndc X and Y coordinates is -1 to +1).
  931.  
  932. { INST
  933.   location ndc
  934.   geom { < xyz.vect }
  935.   transform { .5 0 0 0  0 .5 0 0  0 0 -.009 0   0 0 -.99 1 }
  936. }
  937.  
  938.  
  939. LIST Files
  940. ----------
  941. The conventional suffix for a LIST file is `.list'. 
  942. A list of OOGL objects 
  943. Syntax: 
  944.  
  945. LIST
  946.     oogl-object
  947.     oogl-object
  948.     ...
  949.  
  950. Note that there's no explicit separation between the oogl-objects, so they 
  951. should be enclosed in curly braces ({ }) for sanity.  Likewise there's no 
  952. explicit marker for the end of the list; unless appearing alone in a disk 
  953. file, the whole construct should also be wrapped in braces, as in:
  954.  
  955.    { LIST { QUAD ... } { < xyz.quad } }
  956.  
  957. A LIST with no elements, i.e. { LIST }, is valid, and is the easiest way to 
  958. create an empty object.  For example, to remove a symbol's definition you 
  959. might write
  960.  
  961.    { define somesymbol  { LIST } }
  962.  
  963.  
  964. TLIST Files
  965. -----------
  966. The conventional suffix for a TLIST file is `.grp' ("group") or or `.prj' 
  967. ("projective" matrices).
  968.  
  969. Collection of 4x4 matrices, used in the transforms section of and INST 
  970. object.
  971.  
  972. Syntax: 
  973.  
  974. TLIST            # key word
  975.  
  976. <4x4 matrix (16 floats)>
  977. ...                # Any number of 4x4 matrices
  978.  
  979. TLISTs are used only within the transforms clause of an INST object.  They 
  980. cause the INSTs geom object to be instantiated once under each of the 
  981. transforms in the TLIST. The effect is like that of a LIST of INSTs each 
  982. with a single transform, and all referring to the same object, but is more 
  983. efficient.
  984.  
  985. Be aware that a TLIST is a kind of geometry object, distinct from a 
  986. transform object.  Some contexts expect one type of object, some the other.  
  987. For example in
  988.  
  989. INST transform { : myT } geom { ... }
  990.  
  991. myT must be a transform object, which might have been created with the gcl 
  992.  
  993. (read transform { define myT 1 0 0 1 ... })
  994.  
  995. while in 
  996.  
  997.     INST transforms { : myTs } geom { ... }
  998. or  INST transforms { LIST {: myTs} {< more.prj} } geom { ... }
  999.  
  1000. myTs must be a geometry object, defined e.g. with 
  1001.  
  1002.     (read geometry { define myTs { TLIST 1 0 0 1 ... } })
  1003.  
  1004. A TLIST BINARY format is accepted.  Binary data begins with a 32-bit 
  1005. integer giving the number of transformations, followed by that number of 
  1006. 4x4 matrices in 32-bit floating-point format.  The order of matrix elements 
  1007. is the same as in the ASCII format.
  1008.  
  1009. GROUP Files
  1010. -----------
  1011. This format is obsolete, but is still accepted.  It combined the functions 
  1012. of INST and TLIST, taking a series of transformations and a single Geom 
  1013. (unit) object, and replicating the object under each transformation.
  1014.  
  1015. GROUP ... < matrices > ... unit { oogl-object }
  1016.  
  1017. is still accepted and effectively translated into 
  1018.  
  1019. INST
  1020.     transforms { TLIST ... <matrices> ... }
  1021.     unit { oogl-object }
  1022.  
  1023.  
  1024. DISCGRP Files
  1025. -------------
  1026. This format is for discrete groups, such as appear in the theory of 
  1027. manifolds or in symmetry patterns. This format has its own man page. See 
  1028. discgrp(5). 
  1029.  
  1030. COMMENT Objects
  1031. ---------------
  1032. The COMMENT object is a mechanism for encoding arbitrary data within an 
  1033. OOGL object.  It can be used to keep track of data or pass data back and 
  1034. forth between external modules.  Syntax:
  1035.  
  1036. COMMENT                 # key word
  1037.             
  1038. name type   # individual name and type specifier
  1039. { ... }             # arbitrary data
  1040.  
  1041. The data, which must be enclosed by curly braces, can include anything 
  1042. except unbalanced curly braces.  The type field can be used to identify 
  1043. data of interest to a particular program through naming conventions.  
  1044. COMMENT objects are intended to be associated with other objects through 
  1045. inclusion in a LIST object.  (See section LIST Files.)  The "#" OOGL 
  1046. comment syntax does not suffice for data exchange since these comments are 
  1047. stripped when an OOGL object is read in to Geomview.  The COMMENT object is 
  1048. preserved when loaded into Geomview and is written out intact.  Here is an 
  1049. example associating a WorldWide Web URL with a piece of geometry:
  1050.  
  1051. { LIST 
  1052.  { < Tetrahedron} 
  1053.  {COMMENT GCHomepage HREF { http://www.geom.umn.edu/ }}
  1054. }
  1055.  
  1056. A binary COMMENT format is accepted. Its format is not consistent with the 
  1057. other OOGL binary formats. See section Binary format. The name and type 
  1058. are followed by 
  1059.  
  1060. N Byte1 Byte2 ... ByteN
  1061.  
  1062. instead of data enclosed in curly braces. 
  1063.  
  1064. Non-geometric objects
  1065. =====================
  1066.  
  1067. The syntax of these objects is given in the form used in See section 
  1068. Embedded objects and external-object references, where "quoted" items 
  1069. should appear literally but without quotes, square bracketed ([ ]) items 
  1070. are optional, and | separates alternative choices.
  1071.  
  1072. Transform Objects
  1073. -----------------
  1074. Where a single 4x4 matrix is expected -- as in the INST transform field, 
  1075. the camera's camtoworld transform and the Geomview xform* commands -- use a 
  1076. transform object.
  1077.  
  1078. Note that a transform is distinct from a TLIST, which is a type of 
  1079. geometry. TLISTs can contain one or more 4x4 transformations; "transform" 
  1080. objects must have exactly one. 
  1081.  
  1082. Why have both?  In many places -- e.g. camera positioning -- it's only 
  1083. meaningful to have a single transform.  Using a separate object type 
  1084. enforces this.  Syntax for a transform object is
  1085.  
  1086. <transform> ::= 
  1087.   [ "{" ]             (curly brace, generally needed to make
  1088.                        the end of the object unambiguous.)
  1089.  
  1090.    [ "transform" ]    (optional keyword; unnecessary if the type
  1091.                        is determined by the context, which it
  1092.                        usually is.)
  1093.    [ "define" <name> ]
  1094.                       (defines a transform named <name>, setting
  1095.                        its value from the stuff which follows)
  1096.  
  1097.       <sixteen floating-point numbers>
  1098.                       (interpreted as a 4x4 homogeneous transform
  1099.                given row by row, intended to apply to a
  1100.                        row vector multiplied on its LEFT, so that e.g.
  1101.                        Euclidean translations appear in the bottom row)
  1102.    | 
  1103.       "<" <filename>  (meaning: read transform from that file)
  1104.    |
  1105.       ":" <name>      (meaning: use variable <name>,
  1106.                         defined elsewhere; if undefined the initial
  1107.                         value is the identity transform)
  1108.  
  1109.  [ "}" ]              (matching curly brace)
  1110.  
  1111. The whole should be enclosed in { braces }. Braces are not essential if 
  1112. exactly one of the above items is present, so e.g. a 4x4 array of floats 
  1113. standing alone may but needn't have braces. 
  1114. Some examples, in contexts where they might be used: 
  1115.  
  1116. # Example 1: A gcl command to define a transform
  1117. # called "fred"
  1118.  
  1119. (read transform { transform  define fred
  1120.          1 0 0 0
  1121.          0 1 0 0
  1122.          0 0 1 0
  1123.         -3 0 1 1
  1124.     }
  1125. )
  1126.  
  1127.  
  1128. # Example 2:  A camera object using transform
  1129. # "fred" for camera positioning
  1130. # Given the definition above, this puts the camera at
  1131. # (-3, 0, 1), looking toward -Z.
  1132.  
  1133. { camera
  1134.         halfyfield 1
  1135.         aspect 1.33
  1136.         camtoworld { : fred }
  1137. }
  1138.  
  1139.  
  1140. cameras
  1141. -------
  1142. A camera object specifies the following properties of a camera: 
  1143.  
  1144.    position and orientation 
  1145.  
  1146. specified by either a camera-to-world or world-to-camera transformation; 
  1147. this transformation does not include the projection, so it's typically just 
  1148. a combination of translation and rotation.  Specified as a transform 
  1149. object, typically a 4x4 matrix.  "focus" distance Intended to suggest a 
  1150. typical distance from the camera to the object of interest; used for 
  1151. default camera positioning (the camera is placed at (X,Y,Z) = (0,0,focus) 
  1152. when reset) and for adjusting field-of-view when switching between 
  1153. perspective and orthographic views.  window aspect ratio True aspect ratio 
  1154. in the sense <Xsize>/<Ysize>.  This normally should agree with the aspect 
  1155. ratio of the camera's window.  Geomview normally adjusts the aspect ratio 
  1156. of its cameras to match their associated windows.  near and far clipping 
  1157. plane distances Note that both must be strictly greater than zero.  Very 
  1158. large <far>/<near> distance ratios cause Z-buffering to behave badly; part 
  1159. of an object may be visible even if somewhat more distant than another.  
  1160. field of view Specified in either of two forms.
  1161.  
  1162. @item fov 
  1163.  
  1164. is the field of view -- in degrees if perspective, or linear distance if 
  1165. orthographic -- in the shorter direction.
  1166.  
  1167. @item halfyfield 
  1168.  
  1169. is half the projected Y-axis field, in world coordinates (not angle!), at 
  1170. unit distance from the camera.  For a perspective camera, halfyfield is 
  1171. related to angular field:
  1172.  
  1173.    halfyfield = tan( Y_axis_angular_field / 2 ) 
  1174.  
  1175. while for an orthographic one it's simply: 
  1176.  
  1177.    halfyfield = Y_axis_linear_field / 2 
  1178.  
  1179.  
  1180. This odd-seeming definition is (a) easy to calculate with and (b) 
  1181. well-defined in both orthographic and perspective views.
  1182.  
  1183.  
  1184. The syntax for a camera is: 
  1185.  
  1186. <camera> ::=
  1187.  
  1188.    [ "camera" ]            (optional keyword)
  1189.     [ "{" ]            (opening brace, generally required)
  1190.     [ "define" <name> ]
  1191.  
  1192.     "<" <filename>
  1193.       |
  1194.     ":" <name>
  1195.       |
  1196.                 (or any number of the following,
  1197.                  in any order...)
  1198.  
  1199.     "perspective"  {"0" | "1"}        (default 1)
  1200.                     (otherwise orthographic)
  1201.  
  1202.     "stereo"       {"0" | "1"}        (default 0)
  1203.                     (otherwise mono)
  1204.  
  1205.     "worldtocam" <transform>    (see transform syntax above)
  1206.  
  1207.     "camtoworld" <transform>
  1208.                 (no point in specifying both
  1209.                  camtoworld and worldtocam; one is
  1210.                  constrained to be the inverse of                         the other)
  1211.  
  1212.     "halfyfield" <half-linear-Y-field-at-unit-distance>
  1213.                 (default tan 40/2 degrees)
  1214.  
  1215.     "fov"        (angular field-of-view if perspective,
  1216.              linear field-of-view otherwise.
  1217.              Measured in whichever direction is smaller,
  1218.              given the aspect ratio.  When aspect ratio
  1219.              changes -- e.g. when a window is reshaped --
  1220.              "fov" is preserved.)
  1221.  
  1222.     "frameaspect" <aspect-ratio>    (X/Y) (default 1.333)
  1223.  
  1224.     "near"  <near-clipping-distance>    (default 0.1)
  1225.     
  1226.     "far"    <far-clipping-distance>        (default 10.0)
  1227.  
  1228.     "focus" <focus-distance>        (default 3.0)
  1229.  
  1230.     
  1231.      [ "}" ]                (matching closebrace)
  1232.  
  1233.  
  1234. window
  1235. ------
  1236. A window object specifies size, position, and other window-system related 
  1237. information about a window in a device-independent way. 
  1238. The syntax for a window object is: 
  1239.  
  1240. window ::=
  1241.  
  1242.     [ "window" ]            (optional keyword)
  1243.       [ "{" ]            (curly brace, often required)
  1244.  
  1245.                     (any of the following, in any order)
  1246.  
  1247.         "size"  <xsize> <ysize>
  1248.                 (size of the window)
  1249.  
  1250.         "position"  <xmin> <xmax> <ymin> <ymax>
  1251.                 (position & size)
  1252.  
  1253.  
  1254.         "noborder"
  1255.                 (specifies the window should
  1256.                  have no window border)
  1257.  
  1258.         "pixelaspect"  <aspect>
  1259.                 (specifies the true visual aspect ratio
  1260.                  of a pixel in this window in the sense
  1261.                  xsize/ysize, normally 1.0.
  1262.                  For stereo hardware which stretches the
  1263.                  display vertically by a factor of 2,
  1264.                  "pixelaspect 0.5" might do.
  1265.                  The value is used when computing the
  1266.                  projection of a camera associated with
  1267.                  this window.)
  1268.  
  1269.       [ "}" ]            (matching closebrace)
  1270.  
  1271. Window objects are used in the Geomview window and ui-panel commands to 
  1272. set default properties for future windows or to change those of an 
  1273. existing window. 
  1274.